package com.guide.framework.datasource;

import java.lang.reflect.Method;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.aop.AfterReturningAdvice;
import org.springframework.aop.ThrowsAdvice;

public class DataSourceAfterAdvice implements AfterReturningAdvice, ThrowsAdvice {

	protected static final Logger logger = LoggerFactory.getLogger(DataSourceBeforeAdvice.class);

	public void afterReturning(Object returnValue, Method method, Object[] args, Object target) throws Throwable {
		DynamicDataSourceHolder.clearThreadDataSource();
	}

	public void afterThrowing(Exception ex) {
		logger.error("DataSourceAfterAdvice",ex);
		DynamicDataSourceHolder.clearThreadDataSource();
	}

}
